import { createRouter, createWebHistory } from "vue-router";

// import HomeView from '../views/home.vue'

// import {Record}
import NProgress from 'nprogress'
import 'nprogress/nprogress.css' // 导入样式，否则看不到效果

const modules = import.meta.glob('./modules/*.ts', { eager: true })


const routes = [
  {
    path: '/',
    name: 'home',
    component: () => import('../views/Home.vue')
  },
]

const moduleRoutes = []

// 集成routes模块
for (const path in modules) {
  const routes = (modules[path] as any).default
  moduleRoutes.push(...routes)
}


routes.push(...moduleRoutes)



const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes })


router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})

router.afterEach((to, from) => {
  NProgress.done()

})

export default router